﻿using Bear.Library.Util;
using Bear.Models;
using Emgu.CV;
using Emgu.CV.Structure;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bear.Models
{
    public class DataCenter
    {
        public ActionHelper Action;

        public string _KeyLock = "KeyLock";
        public string _SkillLock = "SkillLock";
        public string _ScreenshotLock = "ScreenshotLock";

        private static DataCenter _DataCenter;

        public Image<Gray, byte> MonsterImage { get; set; }

        public AppConfig Config { get; set; }

        public Bear.Models.Scripts Scripts { get; set; }
        public Maps Maps { get; set; }
        public Players Players { get; set; }


        public Map CurrentMap { get; set; }
        public Player CurrentPlayer { get; set; }
        public Map CurrentScript { get; set; }

        public IntPtr Handle { get; set; }

        public string MathineCode { get; set; }
        public DateTime CurrentTime { get; set; }

        public static DataCenter Load()
        {
            if (_DataCenter == null)
            {
                _DataCenter = new DataCenter();
                _DataCenter.Config = AppConfig.Load();

                // _DataCenter.Scripts = Scripts.Load();
                _DataCenter.Players = Players.Load();
                _DataCenter.Maps = Maps.Load();


                //获取机器码
                MachineCode mathineCode = new MachineCode();

                string disk = mathineCode.GetHDid();

                string mac = mathineCode.GetMoAddress();


                _DataCenter.Action = new ActionHelper();

                //加载验证图片
                _DataCenter.DeathImage = new Image<Gray, byte>("Datas\\Death.png");
                _DataCenter.VerificationImage = new Image<Gray, byte>("Datas\\Verification.png");
                _DataCenter.LoginImage = new Image<Gray, byte>("Datas\\Login.png");
                _DataCenter.MapPointImage = new Image<Gray, byte>("Datas\\MapPoint.png");
                _DataCenter.EnterImage = new Image<Gray, byte>("Datas\\Enter.png");
                _DataCenter.WorldImage = new Image<Gray, byte>("Datas\\World.png");
            }

            return _DataCenter;
        }


        public Image<Gray, byte> DeathImage { get; set; }
        public Image<Gray, byte> VerificationImage { get; set; }
        public Image<Gray, byte> LoginImage { get; set; }
        public Image<Gray, byte> MapPointImage { get; set; }
        public Image<Gray, byte> EnterImage { get; set; }
        public Image<Gray, byte> WorldImage { get; set; }
    }
}
